function Node(val) {
    this.value = val;
    this.left = null;
    this.right = null;
}

const a = new Node('a');
const b = new Node('b');
const c = new Node('c');
const d = new Node('d');
const e = new Node('e');
const f = new Node('f');
const g = new Node('g');
const h = new Node('h');

a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;
e.left = h;

function frontOrder(root) {
    if (root == null) return null;
    console.log(root.value);
    frontOrder(root.left);
    frontOrder(root.right);
}
frontOrder(a)
console.log("中序")

function middleOrder(root) {
    if (root == null) return null;
    frontOrder(root.left);
    console.log(root.value);
    frontOrder(root.right);
}
middleOrder(a)
console.log("后序")

function afterOrder(root) {
    if (root == null) return null;
    frontOrder(root.left);
    frontOrder(root.right);
    console.log(root.value);
}
afterOrder(a)